package game.helper;

import com.badlogic.gdx.Gdx;

import game.entity.AbsSprite;
import game.entity.SpriteManager;
import game.entity.Weapon;
import game.shared.Constants;

public class Shot implements IAbility {

	AbsSprite source;
	int  rocketID;
	float delay;
	float timer;
	float speed;
	SpriteManager weaponManager;
	public Shot(AbsSprite _source, int _rocketID, float _delay, SpriteManager _weaponManager, float _speed)
	{
		this.source = _source;
		this.rocketID = _rocketID;
		this.delay = _delay;
		this.timer = 0;
		this.weaponManager = _weaponManager;
		this.speed = _speed;
		
	}

	@Override
	public void action(AbsSprite sprite) {
		timer += Gdx.graphics.getDeltaTime();
		if(timer >= delay)
		{
			switch(rocketID)
			{
			case Constants.ROCKET_WHITE:
				Weapon rocket = new Weapon(0, weaponManager, "res/img/whiterocket.txt");
				float a = source.getHeight();
				float b = rocket.getHeight();
				rocket.setPosition(source.getX()+source.getWidth(), source.getY() + a - b);
				MovingRight mover = new MovingRight(speed);
				rocket.setMoving(mover);
				weaponManager.add(rocket);
				timer = 0;
				break;
			}
		}
	}

	@Override
	public void actionShape() {
		// TODO Auto-generated method stub
		
	}
}
